#ifndef PLAYER_H
#define PLAYER_H

#include <map>
#include <string>
#include "unitframe.h"
#include "RakPeerInterface.h"
#include "types.h"
#include <SDL/SDL.h>

class Player
{
    private:
        static std::map<RakNet::RakNetGUID, Player*> Players;
        RakNet::RakNetGUID guid;
        std::string name;

        position pos;
        position flag;
        float velX, velY;
        int dir;
        int movementSpeed;

        UnitFrame *myUF;

        SDL_Rect box;
        SDL_Rect myClip[8];
        SDL_Surface *nameText;

        void update_rect();
        void calculate_vel();
        void stop();
        void set_clips();

    public:
        Player(RakNet::RakNetGUID guid, std::string name, int x, int y);
        ~Player();

        static Player* GetPlayerFromGUID(RakNet::RakNetGUID guid);
        static std::map<RakNet::RakNetGUID, Player*> GetPlayerList();

        int hp, mp;
        int maxhp, maxmp;

        void create_flag(int x, int y);
        void move(Uint32 deltaTicks);

        int x();
        int y();
        std::string get_guid();
        std::string get_name();

        void set_x(int x);
        void set_y(int y);

        void draw();
};

#endif // PLAYER_H
